calling a batch file using dxl

Hello all,

I am new to DXL scripting.
here is my problem,
i need to call a vb script from DXL program via batch file and the return value from the vba script should be added to a particular column in DOORS module.

for example, sequence of calling is....
dxl script----->batch file----->vba script

return value from vba script(an integer ) should be updated in
current object in DOORS module

I used system command in DXL script to call batch file and in batch file i have just given path to execute vba script
but,
i am not able get return value from vba script and add to current object in the module

Thanks in advance....
SystemAdmin - Fri Apr 20 05:42:59 EDT 2012

Re: calling a batch file using dxl
cliff.sadler - Fri Apr 20 16:23:26 EDT 2012

A quick thought would be instead of trying to dynamically pass values between such disjointed environments, would be to write the value to a known file, and then come back around with DXL and pick it up later.
There is no mention of timing, though. My experience is that DXL doesn't "wait" for something to get done when you execute system commands, and the batch file is running outside of the visibility of the DXL script.

Re: calling a batch file using dxl
pommCannelle - Wed Jun 17 10:32:32 EDT 2015

In fact you can wait the end of an external treatment ... 
2 methods are availables...

The official one (not well documented i guess ?)

int win32SystemWait_(string cmd, string res, int time_out) 

And the handmade one (you can find them on the smartDXL forum ... )
string command_system (string cmd, int wait_time_in_sec) {
   int wait_time_in_ms = 1000*wait_time_in_sec
   string errmsg = null
   
   // create the lock file : while it exists the command is still running
   string lockfile = tempFileName          // ( os give us a legal temp file )
   string errmsgfile = tempFileName
   Stream out = write lockfile            // create the temp file ... 
   close out
   
   // make the batchfile command 
   string batchfile = tempFileName ".bat"
   out = write batchfile
   out << cmd " 2> \"" errmsgfile "\"\n"    // ( error treatment )
   out << "if %errorlevel% EQU 0 del \"" errmsgfile "\"\n"
   out << "del \"" lockfile "\"\n"
   close out
   
   // run the batchfile command
   system batchfile                  // send the batchfile command to system
         
   // Wait for the batchfile command to end
   int delay_in_ms = 0
   while (fileExists_ lockfile) {         // wait the lock file deletion
       if (delay_in_ms > wait_time_in_ms){   // ( timer )
          // abort if delay > tempo s
          errmsg = "Timeout ! (" wait_time_in_sec " sec)"
          break
       }
       delay_in_ms += 100      
       sleep_(100)                      // sleep_ funcion used for 100 ms
   }
   deleteFile batchfile               // ( clean the batch file )
   
   // return error message if any
   if (null errmsg && fileExists_ errmsgfile){
      errmsg = readFile errmsgfile
   }
   deleteFile errmsgfile
   return errmsg
}

// Add a default timer value -> 30 sec
string command_system (string cmd ) {
   return command_system( cmd"", 30)
}

Be aware that you're waiting the end of the treatment and can't do anything during this time ;)

And to use a known file as buffer to get returned values seems to be the simpliest way ... 

 

Have fun !